<?php
require_once ("../src/db/connectdatabase.php");

function checkEmailRegis($email) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('regis_email');
	$fcon = array('regis_email' => $email);
	$arremailex = $con -> getvalue($tbl, $fn, $fcon);
	
	if(count($arremailex) > 0) {
		return true;
	} else {
		return false;
	}
}

function insertDealer($email, $pass, $name, $gender, $dayofbirth, $mobile, $homephone, $address, $province, $dvct, $dcct, $gtcv, $gtknlv, $codebank, $bank, $datecreate) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('idcode' => '', 'regis_email' => $email, 'regis_pass' => $pass, 'regis_name' => $name, 'gender' => $gender, 'dayofbirth' => $dayofbirth, 'mobile' => $mobile, 'homephone' => $homephone, 'address' => $address, 'province' => $province, 'companywork' => $dvct, 'addresswork' => $dcct, 'introinfowork' => $gtcv, 'introinfokinhnghiem' => $gtknlv, 'cardnumber' => $codebank, 'bankid' => $bank, 'dateregis' => $datecreate);
	return $con -> insert($tbl, $fn);
}

function checkLoginRegis($email, $pass) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('regis_email');
	$fcon = array('regis_email' => $email, 'regis_pass' => $pass);
	$arremailex = $con -> getvalue($tbl, $fn, $fcon);
	
	if(count($arremailex) > 0) {
		return true;
	} else {
		return false;
	}
}

function getDealerLogin($email, $pass) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('regis_email', 'isaccept', 'islock');
	$fcon = array('regis_email' => $email, 'regis_pass' => $pass);
	return $con -> getvalue($tbl, $fn, $fcon);
}

function updateDealer($email, $name, $gender, $dayofbirth, $mobile, $homephone, $address, $province, $dvct, $dcct, $gtcv, $gtknlv, $codebank, $bank) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('regis_name' => $name, 'gender' => $gender, 'dayofbirth' => $dayofbirth, 'mobile' => $mobile, 'homephone' => $homephone, 'address' => $address, 'province' => $province, 'companywork' => $dvct, 'addresswork' => $dcct, 'introinfowork' => $gtcv, 'introinfokinhnghiem' => $gtknlv, 'cardnumber' => $codebank, 'bankid' => $bank);
	$condition = array('regis_email' => $email);
	return $con -> update($tbl, $fn, $condition);
}

function updatePasswordDealer($email, $pass) {
	$con = new ConnectDB();
	
	$tbl = "registrationbank";
	$fn = array('regis_pass' => $pass);
	$condition = array('regis_email' => $email);
	return $con -> update($tbl, $fn, $condition);
}
?>